#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define SIZE_NUM 100
int* randnumscore() {
    // int array[50];
    int* array = (int*)malloc(SIZE_NUM * sizeof(int));
    srand(time(0));

    for (int i = 0; i < SIZE_NUM; i++) {
        array[i] = rand() % 100 + 1;
    }


    printf("成绩列表: [");
    for (int i = 0; i < SIZE_NUM; i++) {
        printf("%d， ", array[i]);
    }
    printf("]\n");

    return array;
}

void cal(int* arr, int n, int* avg, int* max) {
    int sum = 0;
    *max = arr[0];

    for (int i = 0; i < n; i++) {
        sum += arr[i];
        if (arr[i] > *max) {
            *max = arr[i];
        }
    }

    *avg = sum / n;
}

int main() {
    int avg, max;
    int* arr = randnumscore();
    cal(arr, SIZE_NUM, &avg, &max);

    printf("\n最高成绩: %d\n", max);

    printf("平均成绩: %d\n", avg);

    return 0;
}
